﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.PlayerConnectionInternal
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine
{
  [NativeHeader("Runtime/Export/PlayerConnection/PlayerConnectionInternal.bindings.h")]
  internal class PlayerConnectionInternal : IPlayerEditorConnectionNative
  {
    void IPlayerEditorConnectionNative.SendMessage(Guid messageId, byte[] data, int playerId)
    {
      if (messageId == Guid.Empty)
        throw new ArgumentException("messageId must not be empty");
      PlayerConnectionInternal.SendMessage(messageId.ToString("N"), data, playerId);
    }

    bool IPlayerEditorConnectionNative.TrySendMessage(Guid messageId, byte[] data, int playerId)
    {
      if (messageId == Guid.Empty)
        throw new ArgumentException("messageId must not be empty");
      return PlayerConnectionInternal.TrySendMessage(messageId.ToString("N"), data, playerId);
    }

    void IPlayerEditorConnectionNative.Poll() => PlayerConnectionInternal.PollInternal();

    void IPlayerEditorConnectionNative.RegisterInternal(Guid messageId)
    {
      PlayerConnectionInternal.RegisterInternal(messageId.ToString("N"));
    }

    void IPlayerEditorConnectionNative.UnregisterInternal(Guid messageId)
    {
      PlayerConnectionInternal.UnregisterInternal(messageId.ToString("N"));
    }

    void IPlayerEditorConnectionNative.Initialize() => PlayerConnectionInternal.Initialize();

    bool IPlayerEditorConnectionNative.IsConnected() => PlayerConnectionInternal.IsConnected();

    void IPlayerEditorConnectionNative.DisconnectAll() => PlayerConnectionInternal.DisconnectAll();

    [FreeFunction("PlayerConnection_Bindings::IsConnected")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool IsConnected();

    [FreeFunction("PlayerConnection_Bindings::Initialize")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void Initialize();

    [FreeFunction("PlayerConnection_Bindings::RegisterInternal")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void RegisterInternal(string messageId);

    [FreeFunction("PlayerConnection_Bindings::UnregisterInternal")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void UnregisterInternal(string messageId);

    [FreeFunction("PlayerConnection_Bindings::SendMessage")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void SendMessage(string messageId, [Unmarshalled] byte[] data, int playerId);

    [FreeFunction("PlayerConnection_Bindings::TrySendMessage")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern bool TrySendMessage(string messageId, [Unmarshalled] byte[] data, int playerId);

    [FreeFunction("PlayerConnection_Bindings::PollInternal")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void PollInternal();

    [FreeFunction("PlayerConnection_Bindings::DisconnectAll")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void DisconnectAll();

    [Flags]
    public enum MulticastFlags
    {
      kRequestImmediateConnect = 1,
      kSupportsProfile = 2,
      kCustomMessage = 4,
      kUseAlternateIP = 8,
    }
  }
}
